@extends('layouts.back_stage')
@section('content')
    <style>
        /*商品资料*/
        .pro-btn{width:100%;height:40px;margin:30px 0;}
        .head_p{margin:0 auto;}
        .sel_lab{width:220px;line-height:30px;margin-right:10px;margin-bottom: 15px;}
        .pro_sel{width:140px;height: 30px;line-height:30px;float:right;outline:none;font-size: 13px;padding:5px 10px;font-weight: normal;border-radius: 2px;color: #555;background:#fff;background-image: none;border: 1px solid #cfdadd;box-shadow: none;}
        .bt_del{text-align: center;display:inline-block;margin-right:10px;margin-bottom:3px;}
        .material-choose{width:100%;line-height:30px;height:30px;margin:20px auto;}
        .material_div{width:100%;}
        .material{border-collapse:collapse;width:100%;font-size:14px;color:#383838;background:#fff;}
        .material td{text-align:center;height:35px;}
        table,th,td{border:1px solid #ccc;}
    </style>
    <div class="container">
        <div class="pro-btn">
            <h3 style="float:left;">订货会商品资料</h3>
        </div>
        <div>
            <form action="/other-order/other-product-list" method="get">
                <p class="head_p">
                    <label class="sel_lab" >订货编号：<input class="pro_sel girard" type="text" autocomplete="off" autocorrect="off" placeholder="请输入订货编号" value="{{$req->order_num}}" name="order_num" /></label>
                    <label class="sel_lab" style="width:195px;">款号：<input class="pro_sel girard" type="text" autocomplete="off" autocorrect="off" placeholder="请输入款号" value="{{$req->girard}}" name="girard" /></label>
                    <button type="submit" class="btn bt_del btn-info">搜索</button>
                    <a class="btn bt_del btn-info" href="javascript:;" onclick="eliminate()">清空</a>
                </p>
            </form>
        </div>
        <ul class="pro-ul">
            {{--商品资料--}}
            <li id="capital" class="pro-li">
                <div class="material-choose">
                    <span>共<span class="info_sum">{{$infos_count}}</span>条信息</span>
                    <a class="btn btn-info bt_a" href="javascript:;" onclick="addInfos()">添加</a>
                </div>
                <div class="material_div">
                    <table class="material" border="1" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>订货编号</td>
                            <td>款号</td>
                            <td>描述</td>
                            <td>价格/元</td>
                            <td>颜色</td>
                            <td>尺码</td>
                            <td>成分</td>
                            <td>操作</td>
                        </tr>
                        @if(count($infos))
                            @foreach($infos as $k => $v)
                            <tr class="trName">
                                <td>{{$v->order_num}}</td>
                                <td>{{$v->girard}}</td>
                                <td>{{$v->description}}</td>
                                <td>{{$v->price}}</td>
                                <td>{{$v->colors}}</td>
                                <td>{{$v->size}}</td>
                                <td>{{$v->ingredient}}</td>
                                <td>
                                    <a href="/other-order/other-product-update?id={{$v->id}}">修改</a>
                                    <a href="javascript:;" onclick="delTr({{$v->id}})">删除</a>
                                </td>
                            </tr>
                            @endforeach
                        @endif
                    </table>
                    <span style="float:right;"><div style="float: right;margin:20px 0;"><button class="btn btn-info" onclick="returnPage()" style="float:right;">跳转</button><input type="text" class="form-control returnPage" style="width:6rem;float: right;margin:0 5px;"></div>{{$infos->appends(['girard'=>$req->girard,'order_num'=>$req->order_num])->links()}}</span>
                </div>
            </li>
        </ul>
    </div>
    <script>
        /*添加*/
        function addInfos(){
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                url:'/other-order/increase-product',
                data:{
                },
                dataType:'json',
                success:function (data) {
                    if(data.success){
                        window.location.href='/other-order/other-product-update?id='+data.info;
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        }
        /*删除*/
        function delTr(id){
            $(".oText").text("确定要删除吗？");
            $(".oMask").show();
            $(".oAnim").show();
            $(".oBtn0").attr("abc",id);
            $(".oBtn0").attr('id','');
            $(".oBtn0").attr('id','oOShan');
        }
        /*点确定*/
        $(document).on('click','#oOShan',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            var id=$(this).attr("abc");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                url:'/other-order/product-del',
                data:{
                    id:id
                },
                dataType:'json',
                success:function (data) {
                    if(data.success){
                        $(".faceImg").attr("src","/img/laugh.png");
                        $(".oHandle").text("删除成功");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        window.location.reload();
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        });
        /*清空*/
        function eliminate(){
            $(".pro_sel").each(function(){
                $(this).val("");
            })
        }
    </script>
@endsection
